package com.gao.id.strategy;

import com.gao.id.IdGenerator;
import com.gao.id.support.segment.GenSegmentId;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 号段 ID 生成方式
 * MySQL 实现
 */
@Component
public class SegmentId implements IdGenerator {
    private static final Logger logger = LoggerFactory.getLogger(SegmentId.class);

    @Autowired
    private GenSegmentId genSegmentId;

    @Override
    public Long nextId() {
        logger.info("SegmentId get next id");
        genSegmentId.setKey("leaf-segment-test");
        return genSegmentId.getId();
    }
}
